How to refer to the true 'body' of a page? [NOT iFrame body]

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-03-13T03:23:01Z Indexed on 2010/03/13 3:27 UTC
Read the original article Hit count: 130

Filed under:

I have a script that create a new div element. Then, I want to append the div to the body of the page using appendChild method.

The script is look like this :

var div = document.createElement('div');
div.id = 'newdiv';
document.body.appendChild(div);

Unfortunately, the div also appended to the body of iframes. So, my question is, how to refer to the true body of the document, not including the body of the iframes? That way, the div just appended once, to the "true body" of the document. Thanks before, and sorry if my english is bad. :-D

© Stack Overflow or respective owner

Related posts about JavaScript